<?php

declare(strict_types=1);

namespace App\Repository\Article;

use App\Model\ArticleTag;
use App\Repository\BaseRepository;

class ArticleTagRepository extends BaseRepository
{

    /**
     * 批量写入文章标签
     * @param array $data
     * @return bool
     */
    public function batchInsert(array $data): bool
    {
        return ArticleTag::insert($data);
    }

    /**
     * 删除单篇文章所有标签
     * @param int $articleId
     * @return bool
     */
    public function deleteTags(int $articleId): bool
    {
        return ArticleTag::where('article_id', $articleId)->delete() > 0;
    }
}